package 组队604;

import java.util.Scanner;

public class Main {
    static int maxScore = 0;
    static int[][] scores = {
        {97, 90, 0, 0, 0},
        {92, 85, 96, 0, 0},
        {0, 0, 0, 0, 93},
        {0, 0, 0, 80, 86},
        {89, 83, 97, 0, 0},
        {82, 86, 0, 0, 0},
        {0, 0, 0, 87, 90},
        {0, 97, 96, 0, 0},
        {0, 0, 89, 0, 0},
        {95, 99, 0, 0, 0},
        {0, 0, 96, 97, 0},
        {0, 0, 0, 93, 98},
        {94, 91, 0, 0, 0},
        {0, 83, 87, 0, 0},
        {0, 0, 98, 97, 98},
        {0, 0, 0, 93, 86},
        {98, 83, 99, 98, 81},
        {93, 87, 92, 96, 98},
        {0, 0, 0, 89, 92},
        {0, 99, 96, 95, 81}
    };

    public static void main(String[] args) {
        boolean[] selected = new boolean[20];
        dfs(0, 0, selected);
        System.out.println(maxScore);
    }

    static void dfs(int position, int currentSum, boolean[] selected) {
        if (position == 5) {
            if (currentSum > maxScore) {
                maxScore = currentSum;
            }
            return;
        }

        for (int i = 0; i < 20; i++) {
            if (!selected[i] && scores[i][position] > 0) {
                selected[i] = true;
                dfs(position + 1, currentSum + scores[i][position], selected);
                selected[i] = false;
            }
        }
    }
}
